package com.chuangke.common.perty;

import com.chuangke.common.utils.DataUtils;
import com.chuangke.common.utils.ModifiedPropertyInfo;

import java.math.BigDecimal;
import java.util.List;

public class Test {
    public static void main(String[] args) {
        // 修改前数据
        StaffBaseInfoDO oldStaff = new StaffBaseInfoDO();
        oldStaff.setName("张三");
//        oldStaff.setBirthday("1986-01-02");
//        oldStaff.setBirthPlace("北京市");
        oldStaff.setAge(15);
        oldStaff.setMoney(new BigDecimal("243.41"));
        oldStaff.setNum(14.2);

        // 修改后数据
        StaffBaseInfoDO newStaff = new StaffBaseInfoDO();
        newStaff.setName("张三");
//        newStaff.setBirthday("1987-01-02");
//        newStaff.setBirthPlace("山东济南");
        newStaff.setAge(15);
        newStaff.setMoney(new BigDecimal("243.4"));
        newStaff.setNum(14.2);

        List<ModifiedPropertyInfo> differentProperty = DataUtils.getDifferentProperty(oldStaff, newStaff);
        System.out.println("本次修改共计发生"+differentProperty.size()+"处变化，具体如下所示：");
        differentProperty.forEach(diff -> {
            System.out.println(diff.getPropertyName() + "："+ "修改前为【"+diff.getOldValue() + "】，修改后变为【"+diff.getNewValue()+"】");
        });

        System.out.println(DataUtils.isDataValueModifyed(oldStaff, newStaff)) ;

    }

}
